$(function(){
	var lastsel2=0;
	jQuery("#tableTours").jqGrid({
   	url:'/admin/getclientlist',

	datatype: "json",
        mtype: 'POST',
   	colNames:['ID',site, email],
   	colModel:[
   		{name:'id',index:'id', width:55, align:"center",hidden:true},
   		{name:'site',index:'site', width:250,editable:false,align:"center",editrules:{required:true},searchoptions: { sopt: ['eq','ne','bw','ew'] }},
   		{name:'email',index:'email', width:250,editable:false,align:"center",editrules:{required:true,email:true},searchoptions: { sopt: ['eq','ne','bw','ew'] }}
   	],
   	rowNum:10,
   	rowList:[10,20,30],
   	pager: '#pagerTours',
   	sortname: 'id',
    viewrecords: true,
    sortorder: "asc",
    caption:prin,
    onSelectRow: function (id) {
    	jQuery("#tableOtpr").jqGrid().setGridParam({url : '/admin/getOtpr/'+id}).trigger("reloadGrid");
    },
    width:400
});

jQuery("#tableTours").jqGrid('navGrid','#pagerTours',{edit:false,add:false,del:false});


	jQuery("#tableOtpr").jqGrid({
   	url:'/admin/getOtpr/',
	editurl:'/admin/setOtpr/',
	datatype: "json",
        mtype: 'POST',
   	colNames:['ID','',site, email,'idOtpr'],
   	colModel:[
   		{name:'id',index:'id', width:55,key:true, align:"center",editable:true,hidden:true},
   		{name:'checked',index:'checked',width:50,editable:true,edittype:'checkbox'},
   		{name:'site',index:'site', width:250,editable:false,align:"center",editrules:{required:true},searchoptions: { sopt: ['eq','ne','bw','ew'] }},
   		{name:'email',index:'email', width:250,editable:false,align:"center",editrules:{required:true,email:true},searchoptions: { sopt: ['eq','ne','bw','ew'] }},
   		{name:'idPrin',index:'idPrin',width:50,editable:false,editable:true,hidden:true}
   		],
   	rowNum:10,
   	rowList:[10,20,30],
   	pager: '#pagerOtpr',
   	sortname: 'id',
    viewrecords: true,
    sortorder: "asc",
    caption:otpr,
    onSelectRow: function (id) {
   				if (id && id !== lastsel2) {

	                   	jQuery('#tableOtpr').jqGrid('restoreRow', lastsel2);
	                	jQuery('#tableOtpr').jqGrid('editRow', id, true);
	                    lastsel2 = id;
	                }
    },
    width:400
});
jQuery("#tableOtpr").jqGrid('navGrid','#pagerOtpr',{edit:false,add:false,del:false});


});